package controller

import (
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	"net/http"
	"start/app/user/api/controller/vo"
	"start/pkg/prometheus/http/httpprometheus"
)

type Controller struct{}

func (_ Controller) send(body vo.Body) (int, any) {
	if body.Code == 0 {
		body.Code = http.StatusOK
	}
	if body.Msg == "" {
		body.Msg = "success"
	}
	return body.Code, body
}

func SetUp() *gin.Engine {
	gin.SetMode(gin.ReleaseMode) // 设置为发布模式，默认开发模式

	router := gin.New()

	// 普罗米修斯
	httpprometheus.Use(router)

	// 设置静态资源目录
	//router.Static("/assets", "./assets")

	// http://127.0.0.1:8090/swagger/index.html
	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	NewHealth(router)
	NewUser(router)
	return router
}
